local joyex__lijian = fk.CreateSkill {

  name = "joyex__lijian",

  tags = {  },

}



joyex__lijian:addEffect("active", {
  name = "joyex__lijian",
  anim_type = "offensive",
  card_num = 1,
  target_num = 2,
  prompt = "#joyex__lijian",
  can_use = function(self, player)
    return player:usedSkillTimes(joyex__lijian.name, Player.HistoryPhase) < 2
  end,
  card_filter = function(self, player, to_select, selected)
    return #selected == 0 and not player:prohibitDiscard(Fk:getCardById(to_select))
  end,
  target_filter = function(self, player, to_select, selected)
    if #cards ~= 1 then return false end
    local target = Fk:currentRoom():getPlayerById(to_select)
    if target:getMark("joyex__lijian-turn") == 0 then
      if #selected == 0 then
        return true
      elseif #selected == 1 then
        return not target:isProhibited(Fk:currentRoom():getPlayerById(selected[1]), Fk:cloneCard("duel"))
      else
        return false
      end
    end
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    room:throwCard(effect.cards, joyex__lijian.name, player, player)
    room:useVirtualCard("duel", nil, room:getPlayerById(effect.tos[2]), effect.tos[1], joyex__lijian.name)
  end,
})

joyex__lijian:addEffect(fk.PreDamage, {
  refresh_events = {fk.PreDamage},
  can_refresh = function(self, event, target, player, data)
    return target == player and data.card and table.contains(data.card.skillNames, joyex__lijian.name)
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:setPlayerMark(data.to, "joyex__lijian-turn", 1)
  end,
})

return joyex__lijian